from typing import Dict


class IDGenerator:
    def __init__(self):
        self.counter: Dict[str, int] = {}

    def new_id(self, tag: str, lineno: int = -1):
        lineno_str = "_" if lineno <= 0 else "_line_" + str(lineno) + "_"
        if tag not in self.counter:
            self.counter[tag] = 0
        name = tag + lineno_str + str(self.counter[tag])
        self.counter[tag] += 1
        return name


id_generator = IDGenerator()
